<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script>
			function $$(id){
				return document.getElementById(id);
			}
			window.onload = function () {
				var cnv = $$("canvas");
				var cxt = cnv.getContext("2d");
				
				cxt.save();
				cxt.beginPath();
				cxt.arc(70,70,50,0,360*Math.PI/180,true);
				cxt.closePath();
				cxt.stroke();
				cxt.clip();
				
				var image = new Image();
				image.src = "img/1.png";
				image.onload = function(){
					cxt.drawImage(image,10,20);
				}
				$$("btn").onclick = function(){
					cxt.restore();
					cxt.clearRect(0,0,cnv.width,cnv.height);
					var image = new Image();
					image.src = "img/1.png";
					image.onload = function(){
						cxt.drawImage(image,10,20);
					}
				}
				
				
			}
		</script>
	</head>
	<body>
		<canvas id="canvas" width="200" height="180" style="border:1px dashed gray;"></canvas>
		<input id="btn" type="button" value="绘制新图" />
	</body>
</html>
